package com.thz.houserental.infrastructure.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.thz.houserental.infrastructure.table.LogRecord;
import com.thz.houserental.infrastructure.web.dto.LogPageDto;
import com.thz.houserental.infrastructure.web.mapper.LogMapper;
import com.thz.houserental.infrastructure.web.service.LogService;
import org.springframework.stereotype.Service;

@Service
public class LogServiceImpl extends ServiceImpl<LogMapper, LogRecord> implements LogService {
    @Override
    public IPage<LogRecord> QueryAllLog(Integer pageNo, Integer pageSize) {
        Page page = new Page(pageNo, pageSize);
        IPage<LogRecord> iPage = this.baseMapper.selectPage(page, new LambdaQueryWrapper<>());
        return iPage;
    }

    @Override
    public IPage<LogRecord> QueryAllLogByOpUser(LogPageDto logPageDto) {
        Page page = new Page(logPageDto.getPageNo(), logPageDto.getPageSize());
        LambdaQueryWrapper<LogRecord> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(LogRecord::getOperator, logPageDto.getOperator());
        IPage<LogRecord> iPage = this.baseMapper.selectPage(page, wrapper);
        return iPage;
    }
}
